package com.tsingteng.cosfun.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.tsingteng.cosfun.common.Config;


/**
 * 描述:缓存工具类
 * 创建人: 肖利
 *时间: 2018/7/30
 * qq: (872179966)
 */
public class CookieUtils {
    private static Context mContext;


    public static void init(Context context) {
        mContext=context;
    }
    /**
     * 存
     * @param key
     * @param value
     */
    public static void put(String key, Object value) {
        SharedPreferences sp = mContext.getSharedPreferences(Config.USER_INFO, Context.MODE_PRIVATE);
        SharedPreferences.Editor et = sp.edit();
        if (value instanceof String) {
            et.putString(key, (String) value);
        } else if (value instanceof Integer) {
            et.putInt(key, (Integer) value);
        } else if (value instanceof Boolean) {
            et.putBoolean(key, (Boolean) value);
        } else if (value instanceof Float) {
            et.putFloat(key, (Float) value);
        } else if (value instanceof Long) {
            et.putLong(key, (Long) value);
        }
        et.commit();
    }
}
